<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
      <input type="text" id="username">
      <input type="text" id="password">
      <button id="btn">登录</button>
    </div>
    <script>
       let btn = document.getElementById('btn')
    btn.addEventListener('click', () => {
     const username=document.getElementById('username').value
     const password=document.getElementById('password').value
     fetch(`http://localhost:3000/login?username=${username}&password=${password}`)
          .then(res => res.text())
          .then(msg => alert(msg))
          .catch(() => alert('登录失败'));


    })
    </script>
</body>
</html>